home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_10_07 / 1007054a < prev    next >
Text File  |  1992-05-04  |  765b  |  33 lines

  1. z#include <iostream.h>
  2.  
  3. class rational
  4.     {
  5. public:
  6.     rational();
  7.     rational(long n, long d = 1);
  8.     rational &operator+=(rational r);
  9.     rational &operator-=(rational r);
  10.     rational &operator*=(rational r);
  11.     rational &operator/=(rational r);
  12.     rational operator+();
  13.     rational operator-();
  14.     double to_double();
  15.     friend ostream &operator<<(ostream &os, rational
  16. r);
  17. private:
  18.     long num, denom;
  19.     void simplify();
  20.     };
  21.  
  22. rational operator+(rational r1, rational r2);
  23. rational operator-(rational r1, rational r2)
  24. rational operator*(rational r1, rational r2)
  25. rational operator/(rational r1, rational r2)
  26.  
  27. rational operator++(rational &r)
  28. rational operator--(rational &r)
  29. rational operator++(rational &r, int);
  30. rational operator--(rational &r, int);
  31.  
  32.  
  33.